<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('系统管理员操作界面')"/>
    <!--<th:block th:include="include :: select2-css" />-->
    <th:block th:include="include :: bootstrap-select-css"/>
    <link th:href="@{/ruoyi/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/ruoyi/css/jquery-confirm.min.css}" rel="stylesheet"/>
</head>
<style type="text/css">
    /**手机屏幕下显示***/
    @media screen and (max-width: 768px) {
        .gray-bg {
            height: auto;
            margin: auto;
        }

        .image {
            position: absolute;
            margin-top: -50px;
            margin-left: 50px;
            left: 55%;
            width: 30%;
        }
    }

    /**电脑屏幕下显示***/
    @media screen and (min-width: 768px) {
        .gray-bg {
            height: auto;
            width: 70%;
            margin: auto;
        }

        .image {
            position: absolute;
            margin-top: -50px;
            margin-left: 200px;
            left: 55%;
        }

        #sbwhform {
            height: 220px;
            margin: -30px 0px 0px 0px;
        }

        #weihr_div > #weihr_update_input_15 {
            margin-top: 15px;
            margin-left: -40px;
            background-color: #FFFFFF;
            border: none;
        }

        #weihr_lab {
            margin-top: 17px;
        }

        #gzyy_div {
            margin-left: -20px;
        }

        #selbm_div {
            margin-left: -20px;
            width: 165px;
        }

        #shiyr_lab {
            margin-left: -30px;
        }

        #shiyr01 {
            margin-left: -20px;
        }

        #add_yg {
            margin-left: -20px;
            background-color: #1e84c5;
            color: #FFFFFF;
        }

        #jjfa_div {
            margin-left: -20px;
        }

        #add_jjfa_div {
            margin-left: -10px;
        }

        #add_yg_div {
            margin-left: -10px;
        }

        #add_jjfa {
            background-color: #1e84c5;
            color: #FFFFFF;
        }
    }
</style>

<body class="gray-bg">

<!--添加员工模态框开始-->
<div class="tjjjfa">
    <div class="modal fade" id="ygModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="tjygModalLabel">人员管理</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="form-group" style="display: none">
                            <label class="col-sm-3 control-label">部门id号(隐藏)</label>
                            <div class="col-sm-9">
                                <input type="text" name="bmid" class="form-control" id="yg_bmid"
                                       placeholder="请输入账户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">部门名称</label>
                            <div class="col-sm-9">
                                <input type="text" name="bmmc" class="form-control" id="yg_bmmc"
                                       placeholder="请输入账户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">姓名</label>
                            <div class="col-sm-3">
                                <input type="text" name="xingm" class="form-control" id="yg_xingm"
                                       placeholder="请输入员工姓名">
                                <span class="help-block"></span>
                            </div>
                            <div class="col-sm-3">
                                <input type="text" name="zjm" class="form-control" id="yg_zjm" disabled
                                       placeholder="请输入员工姓名">
                                <span class="help-block"></span>
                            </div>
                            <div class="col-sm-3">
                                <a class="btn btn-primary btn-rounded btn-sm" id="creat_zjm_btn">
                                    <i class="fa fa-search"></i>生成助记码</a>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="tj_yg_btn" onclick="tjyg()">添加</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--添加员工模态框结束-->

<!--添加解决方案模态框开始-->
<div class="tjjjfa">
    <div class="modal fade" id="tjjjfaModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="tjModalLabel">添加解决方案</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="form-group" style="display: none">
                            <label class="col-sm-2 control-label">生成ID</label>
                            <div class="col-sm-8">
                                <input type="text" name="id" class="form-control" id="idhao"
                                       placeholder="请点击生成ID号">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group" style="display: none">
                            <label class="col-sm-3 control-label">父ID号</label>
                            <div class="col-sm-9">
                                <input type="text" name="parentId" class="form-control" id="parent_id"
                                       placeholder="请输入账户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group" style="display: none">
                            <label class="col-sm-4 control-label">ancestors</label>
                            <div class="col-sm-8">
                                <input type="text" name="ancestors" class="form-control" id="ancestors"
                                       placeholder="请输入账户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">故障原因</label>
                            <div class="col-sm-8">
                                <input type="text" name="gzyy" class="form-control" id="gzyy_fl" disabled
                                       placeholder="请输入账户名">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">解决方案</label>
                            <div class="col-sm-8">
                                <input type="text" name="name" class="form-control" id="jjfa_name"
                                       placeholder="请输入解决方案">
                                <span class="help-block"></span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="tj_jjfa_btn" onclick="tjjjfa()">添加</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--添加解决方案模态框结束-->

<!--设备报废模态框开始-->
<div class="modal fade" id="sbbaofModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="sbbfModalLabel">设备报废</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">设备ID号(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="sbid" class="form-control" id="sbid_bf"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">设备编号(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="sbbh" class="form-control" id="sbbh_bf"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">设备编号(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="bmid" class="form-control" id="bmid_bf"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">修改前的内存大小(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="ncggdx" class="form-control" id="ncggdx_bf"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">购买日期(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="gmrq" class="form-control" id="gmrq_bf"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">报废申请编号</label>
                        <div class="col-sm-8">
                            <input type="text" name="bfsqbh" class="form-control" id="bfsqbh_bf"
                                   placeholder="请输入设备报废申请编号">
                            <span class="help-block"></span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="bf_save_btn" onclick="baofei()">升级</button>
            </div>
        </div>
    </div>
</div>
<!--设备报废模态框结束-->

<!--设备升级模态框开始-->
<div class="modal fade" id="sbshenjModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="sbModalLabel">设备升级</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">修改前的内存大小(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="sjshuom" class="form-control" id="ncggdx"
                                   placeholder="请输入修改前的内存大小">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">升级后大小</label>
                        <div class="col-sm-9">
                            <input type="text" name="sjshuom" class="form-control" id="sbsj_ncggdx"
                                   placeholder="请输入升级后内存大小">
                            <input type="hidden" name="ncggdx" class="form-control" id="ncggdx01"
                                   placeholder="请输入内存大小">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">设备id号(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="sbid" class="form-control" id="sbsj_sbid"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label class="col-sm-4 control-label">设备编号(隐藏)</label>
                        <div class="col-sm-8">
                            <input type="text" name="sbbh" class="form-control" id="sbsj_sbbh"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">来源设备编号</label>
                        <div class="col-sm-9">
                            <select name="ly_sbbh" class="form-control m-b" id="ly_sbbh">
                            </select>
                            <input type="hidden"  class="form-control" id="ly_ncggdx"
                                   placeholder="请输入来源设备内存大小">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="sj_save_btn" onclick="shengji()">升级</button>
            </div>
        </div>
    </div>
</div>
<!--设备升级模态框结束-->

<!--点击维护后打开的登录的模态框开始-->
<div class="modal fade" id="empAddModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     data-backdrop="static"
     data-keyboard="false">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">管理员登录</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div id="error_box"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" name="loginName" class="form-control" id="uname"
                                   placeholder="请输入账户名">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="password" name="loginPassword" class="form-control" id="upass"
                                   placeholder="请输入密码">
                            <span class="help-block"></span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="emp_save_btn" onclick="login()">登录</button>
            </div>
        </div>
    </div>
</div>
<!--点击维护后打开的登录的模态框结束-->


<!--维护模态框开始-->
<div class="sbwhmodal">
    <div class="modal fade" id="myModal5" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static"
         data-keyboard="false">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span>
                    </button>
                    <h3 class="modal-title"><strong>设备维护</strong></h3>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" id="sbwhform">
                        <div class="form-group" style="display: none">
                            <label class="col-sm-2 control-label">设备id号(隐藏)</label>
                            <div class="col-sm-10">
                                <input type="text" name="sbid" class="form-control" id="sbid_update_input_15">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group" style="display: none">
                            <label class="col-sm-2 control-label">设备编号(隐藏)</label>
                            <div class="col-sm-10">
                                <input type="text" name="sbbh" class="form-control" id="sbbh_update_input_15">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">故障原因</label>
                            <div class="col-sm-10" id="gzyy_div">
                                <select name="gzyy" class="form-control" id="gzyy_update_input_15">
                                </select>
                                <span class="help-block"></span>
                                <input type="hidden" name="ancestors" class="form-control" id="ancestorsfrowh">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">解决方案</label>
                            <div class="col-sm-7" id="jjfa_div">
                                <select name="jjfa" class="form-control" id="jjfa_update_input_15">
                                </select>
                                <span class="help-block"></span>
                            </div>
                            <input type="hidden" name="whjl" id="whjl_input">
                            <div class="col-sm-2" id="add_jjfa_div">
                                <button type="button" class="btn btn-white" id="add_jjfa">添加解决方案</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">部门名称</label>
                            <div class="col-sm-4" id="selbm_div">
                                <select name="bmid" class="form-control" id="selectbm">
                                </select>
                                <input type="hidden" id="bmmc_hidden">
                                <input type="hidden" id="ybmmc" name="ybmmc">
                            </div>
                            <label class="col-sm-2 control-label" id="shiyr_lab">使用人</label>
                            <div class="col-sm-3">
                                <input name="shiyr" id="shiyr01" style="background-color: #FFFFFF" class="form-control" list="browsers"><datalist id="browsers"></datalist>
                                <span class="help-block"></span>
                                <input type="hidden" id="yshiyr" name="yshiyr">
                            </div>
                            <div class="col-sm-1" id="add_yg_div">
                                <button type="button" class="btn btn-white" id="add_yg">人员管理</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" id="weihr_lab" style="color: #9b9b9b">维护人：</label>
                            <div class="col-sm-4" id="weihr_div">
                                <input type="text" name="weihr" class="form-control" id="weihr_update_input_15"
                                       style="color: #9b9b9b"
                                       readonly="readonly">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-white" id="sbwh_insert_btn" onclick="savesbwh()">
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!--编辑模态框结束-->

<div class="main-content">
    <table class="table table-bordered" th:each="sbxxb : ${sbxxb}" th:id="${sbxxb.id}">
        <div class="row">
            <div class="col-sm-12 text-right">
                <h1 class="font-bold text-center">计算机设备登记表</h1>
                <small class="font-bold">HWGA-QR-114-2017-01</small>
            </div>
        </div>
        <thead style="background-color: #8DB4E2">
        <tr>
            <th colspan="4"><h3 class="font-bold text-center">设备详情</h3></th>
        </tr>
        </thead>
        <tbody><img class="image" th:style="${sbxxb.bfbs}=='1' ? '' :'display:none'" src="/img/baofei.png"/>
        <tr>
            <th scope="row" class="text-center">设备编号</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.sbbh}" th:id="${sbxxb.sbbh}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">设备名称</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.sbmc}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">品牌型号</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.shccj}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="col-sm-1 text-center">购买时间</th>
            <td class="text-center col-sm-4" th:text="${sbxxb.gmrq}">2019-12-31</td>
            <th scope="row" class="col-sm-2 text-center">显示器购买时间</th>
            <td class="text-center col-sm-5">/</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.beiz}"></td>
        </tr>
        </tbody>
        <thead>
        <tr>
            <th colspan="4"><h3 class="font-bold text-center">配置参数</h3></th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <th scope="row" class="text-center">CPU</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.cpuxh}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">主板</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.zbxh}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">内存</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.ncggdx}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">硬盘</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.ypdx}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">显卡</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.sbbh}">集成</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">MAC</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.macdz}">Larry the Bird</td>
        </tr>
        <tr>
            <th scope="row" class="text-center">备注</th>
            <td colspan="3" class="text-center" th:text="${sbxxb.beiz}">Larry the Bird</td>
        </tr>
        </tbody>
    </table>
    <div style="margin-top: -21px">
        <table class="table table-bordered">
            <thead style="background-color: #8DB4E2">
            <tr>
                <th colspan="4"><h3 class="font-bold text-center">维护记录</h3></th>
            </tr>
            </thead>
        </table>
    </div>
    <div style="overflow-y: scroll;max-height: 176px;margin-top: -21px">
        <table class="table table-bordered">
            <tbody>
            <tr th:each="sbwhb : ${sbwhb}">
                <td colspan="4" class="text-center"
                    th:text="${sbwhb.whjl}">Larry the Bird
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="btn-group-lg" id="toolbar" role="group" align="center" th:each="sbxxb : ${sbxxb}"
         th:style="${sbxxb.bfbs}=='1' ? 'display:none' :''">
        <button class="btn btn-success" onclick="updatetjmtk()" id="whid">
            <i class="fa fa-pencil"></i>设备维护
        </button>
        <button class="btn btn-danger" onclick="sbsj()" id="sbsj">
            <i class="fa fa-remove"></i>设备升级
        </button>
        <button class="btn btn-info" onclick="sbbf()" id="sbbf">
            <i class="fa fa-remove"></i>设备报废
        </button>
    </div>
</div>

<th:block th:include="include :: footer"/>
<!--<th:block th:include="include :: select2-js" />-->
<th:block th:include="include :: bootstrap-select-js"/>
<script th:src="@{/ruoyi/js/jquery-confirm.min.js}"></script>
<script th:src="@{/ruoyi/js/jquery.form.js}"></script>
<script type="text/javascript">
    var username = ""
    var ancestors = ""
    var sessionname = "[[${session.username}]]"
    var spid = document.getElementsByTagName("td")[0].firstChild.nodeValue;

    function login() {
        var loginName = $("#uname").val();
        var loginPassword = $("#upass").val();
        var spid = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        $.ajax({
            url: "/nc/sysUser/login/" + loginName + "/" + loginPassword,
            type: 'GET',
            success: function (result) {
                username = result[0].userName;
                if (result != null) {
                    $("#empAddModal").modal('hide');
                    $("#myModal5").modal({
                        backdrop: "static"
                    });
                    $.ajax({
                        url: "/nc/sbxxb/getsbwh/" + spid,
                        type: 'GET',
                        success: function (result) {
                            //console.log(retult);
                            $("#sbid_update_input_15").val(result[0].id);
                            $("#sbbh_update_input_15").val(result[0].sbbh);
                            $("#emp_update_btn").val(result[0].sbbh);
                            $("#weihr_update_input_15").val(username);
                            $("#selectbm").val(result[0].bmid);
                            $("#shiyr01").val(result[0].shiyr);
                            $.ajax({
                                url: "/nc/sbflb/getname/",
                                type: 'GET',
                                success: function (data) {
                                    $('#gzyy_update_input_15').empty();
                                    var options = "";   //字符串拼接
                                    $("#gzyy_update_input_15").append('<option value="0">请选择故障原因</option>');
                                    for (var i in data) {  //遍历json数组
                                        options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                                        //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                                    }
                                    $('#gzyy_update_input_15').append(options);
                                }
                            })
                        }
                    });
                }
            },
            error: function () {
                alert("您好，你输入的用户名和密码不匹配，请核对后重新登录，谢谢您的合作！！！");
                window.location.href = "/nc/sbxxb/sbwh/" + spid;
            }
        })
    }

    function sbsj() {
        var spid = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        $('#sbshenjModal').modal({
            backdrop: "static"
        });
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + spid,
            type: 'GET',
            success: function (result) {
                $("#ncggdx").val(result[0].ncggdx);
                $("#sbsj_sbid").val(result[0].id);
                $("#sbsj_sbbh").val(result[0].sbbh);
                $.ajax({
                    url: "/nc/sbbfb/getsbbf/",
                    type: 'GET',
                    success: function (data) {
                        $('#ly_sbbh').empty();
                        var options = "";   //字符串拼接
                        $("#ly_sbbh").append('<option value="">请选择来源设备编号</option>');
                        for (var i in data) {  //遍历json数组
                            options += "<option value='" + data[i].sbbh + "'>" + data[i].sbbh + "</option>"
                            //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                        }
                        $('#ly_sbbh').append(options);
                    }
                })
            }
        })
    }

    function sbbf() {
        var spid = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        $('#sbbaofModal').modal({
            backdrop: "static"
        });
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + spid,
            type: 'GET',
            success: function (result) {
                $("#bmid_bf").val(result[0].bmid)
                $("#ncggdx_bf").val(result[0].ncggdx);
                $("#sbid_bf").val(result[0].id);
                $("#sbbh_bf").val(result[0].sbbh);
                $("#gmrq_bf").val(result[0].gmrq);
            }
        })
    }

    // 点击编辑按钮弹出模态框。
    function updatetjmtk() {
        sessionname = "[[${session.username}]]"
        if (sessionname == "") {
            $.confirm({
                title: '请输入管理员账号与密码',
                content: '' +
                    '<form action="" class="formName">' +
                    '<div class="form-group">' +
                    '<input type="text" placeholder="请输入用户名" class="name form-control"/>' +
                    '<input type="password" placeholder="请输入密码" class="name form-control"/>' +
                    '</div>' +
                    '</form>',
                buttons: {
                    login: {
                        text: '登录',
                        btnClass: 'btn-blue',
                        action: function () {
                            var loginName = this.$content.find('.name').val();
                            var loginPassword = this.$content.find('.ypdx').val();
                            // $.ajax({
                            //     url: "/nc/sysUser/login/" + loginName + "/" + loginPassword,
                            //     type: 'GET',
                            //     success: function (result) {
                            //
                            //     }
                            // })

                            var self = this;
                            self.setContent('Checking callback flow');
                            return $.ajax({
                                url: "/nc/sysUser/login/" + loginName + "/" + loginPassword,
                                // dataType: 'json',
                                method: 'get'
                            }).done(function (response) {
                                window.location.href = window.location.href;
                            }).fail(function () {
                                alert("您好，你输入的用户名和密码不匹配，请核对后重新登录，谢谢您的合作！！！");
                                window.location.href = window.location.href;
                                // }).always(function(){
                                //     self.setContentAppend('<div>Always!</div>');
                            });
                        }
                    },
                    cancel: {
                        text: '取消',
                        btnClass: 'btn-red',
                        action: function () {
                            //close
                            // $('#sbAddModal').modal('show');
                        },
                    },
                },
            });
        } else {
            show()
        }
    }

    function show() {
        sessionname = "[[${session.username}]]"
        $("#myModal5").modal({
            backdrop: "static"
        });
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + spid,
            type: 'GET',
            success: function (result) {
                //console.log(retult);
                $("#sbid_update_input_15").val(result[0].id);
                $("#sbbh_update_input_15").val(result[0].sbbh);
                $("#emp_update_btn").val(result[0].sbbh);
                $("#weihr_update_input_15").val(sessionname);
                $("#selectbm").val(result[0].bmid);
                $("#bmmc_hidden").val(result[0].bmid);
                $("#ybmmc").val(getbmmcsjk(result[0].bmid))
                $("#yshiyr").val(getshiyr(spid))
                $("#shiyr01").val(result[0].shiyr);
                $("#shiyr01").attr("readonly","readonly")
                $("#browsers").val(result[0].shiyr);
                $('#gzyy_update_input_15').val(0)
                $('#jjfa_update_input_15').val(0)
                $.ajax({
                    url: "/nc/sbflb/getname/",
                    type: 'GET',
                    success: function (data) {
                        $('#gzyy_update_input_15').empty();
                        var options = "";   //字符串拼接
                        $("#gzyy_update_input_15").append('<option value="0">请选择故障原因</option>');
                        for (var i in data) {  //遍历json数组
                            options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                            //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                        }
                        $('#gzyy_update_input_15').append(options);
                    }
                })
            }
        });
    }

    // function updatetjmtk() {
    //     sessionname="[[${session.username}]]"
    //     if (sessionname == "") {
    //         $("#empAddModal").modal({
    //             backdrop: "static"
    //         });
    //     } else {
    //         $("#myModal5").modal('show');
    //         // $("#myModal5").modal({
    //         //     backdrop: "static"
    //         // });
    //         // $("#myModal5").modal('show');
    //         // window.location.href = window.location.href;
    //         $.ajax({
    //             url: "/nc/sbxxb/getsbwh/" + spid,
    //             type: 'GET',
    //             success: function (result) {
    //                 //console.log(retult);
    //                 $("#sbid_update_input_15").val(result[0].id);
    //                 $("#sbbh_update_input_15").val(result[0].sbbh);
    //                 $("#emp_update_btn").val(result[0].sbbh);
    //                 $("#weihr_update_input_15").val(username);
    //                 $("#selectbm").val(result[0].bmid);
    //                 $("#shiyr01").val(result[0].shiyr);
    //                 // window.location.href = window.location.href;
    //                 $.ajax({
    //                     url: "/nc/sbflb/getname/",
    //                     type: 'GET',
    //                     success: function (data) {
    //                         $('#gzyy_update_input_15').empty();
    //                         var options = "";   //字符串拼接
    //                         $("#gzyy_update_input_15").append('<option value="">请选择故障原因</option>');
    //                         for (var i in data) {  //遍历json数组
    //                             options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
    //                             //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
    //                         }
    //                         $('#gzyy_update_input_15').append(options);
    //                     }
    //                 })
    //             }
    //         });
    //     }
    // };

    $("#whid").click(function () {
        getDepts("#myModal5 select");
    });

    function getDepts(ele) {
        $.ajax({
            url: "/nc/bmxxb/getbmxx/",
            type: 'get',
            success: function (data) {
                $('#selectbm').empty();
                var options = "";   //字符串拼接
                $("#selectbm").append('<option value="">请选择部门</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].id + "'>" + data[i].bmmc + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#selectbm').append(options);
            },
        });
    };

    $('#gzyy_update_input_15').change(function () {
        var sbwhid = $("#gzyy_update_input_15 option:selected").val();
        $.ajax({
            url: "/nc/sbflb/getans/" + sbwhid,
            type: 'GET',
            async: false,
            success: function (result) {
                $("#ancestorsfrowh").empty();
                for (var i in result) {
                    $("#ancestorsfrowh").val(result[i].ancestors)
                }
                ancestors = $("#ancestorsfrowh").val(result[i].ancestors)
            }
        });
        $.ajax({
            url: "/nc/sbflb/getnamebyans/" + sbwhid,
            type: 'GET',
            async: false,
            success: function (data) {
                $('#jjfa_update_input_15').empty();
                var options = "";   //字符串拼接
                $("#jjfa_update_input_15").append('<option value="0">请选择解决方案</option>');
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#jjfa_update_input_15').append(options);
            }

        })
    })

    $('#selectbm').change(function () {
        var bmid = $("#selectbm option:selected").val();
        $('#shiyr01').val("");
        $('#browsers').empty();
        $("#shiyr01").removeAttr("readonly")
        $.ajax({
            url: "/nc/ygxxb/getygxx/" + bmid,
            type: 'get',
            success: function (data) {
                $('#shiyr01').empty();
                var options = "";   //字符串拼接
                for (var i in data) {  //遍历json数组
                    options += "<option value='" + data[i].xingm + "'>" + data[i].zjm + "</option>"
                    //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                }
                $('#browsers').append(options);
            },
        });
    });

    $("#shiyr01").change(function () {
        var sjkshiyr = getshiyr(spid)//得到当前数据库中使用人
        var shiyr = $("#shiyr01").val()//得到当前表单的使用人
        var bmid = getdeptbyshiyr(shiyr)//得到当前表单使用人的部门id
        var bmidforbd = $("#selectbm").val()//得到当前表单的部门id
        var sjkbmid = getbmid(spid)//得到当前数据库中使用人的部门id
        if (bmid==0) {
            alert("全公司上下查无此人，请认真核对后选择")
            $("#shiyr01").val(sjkshiyr)
            $("#shiyr01").attr("readonly","readonly")
        }if (bmid!=0&&bmid!=bmidforbd) {
            $.confirm({
                title: '调整部门',
                content: '你当前的操作在维护使用人的部门，确定该人员调整了部门吗？',
                buttons: {
                    confirm: {
                        text: '确定',
                        btnClass: 'btn-blue',
                        action: function(){
                            $("#shiyr01").attr("readonly","readonly")
                        }
                    },
                    cancel: {
                        text: '取消',
                        btnClass: 'btn-blue',
                        action: function(){
                            $("#shiyr01").val(sjkshiyr)
                            $("#shiyr01").attr("readonly","readonly")
                        }
                    }
                }
            });
        }if (bmid!=0&&bmid==bmidforbd) {
            alert("通过")
            $("#shiyr01").attr("readonly","readonly")
        }
    })
    // 获取当前日期
    function getdate() {
        var d = new Date();
        var y = d.getFullYear();
        var m = d.getMonth() + 1;
        var d = d.getDate();
        if (m < 10) m = "0" + m;
        if (d < 10) d = "0" + d;
        return y + "-" + m + "-" + d
    }

    $("#jjfa_update_input_15").change(function () {
        var gzyy = $("#gzyy_update_input_15 option:selected").text();
        var jjfa = $("#jjfa_update_input_15 option:selected").text();
        var index = gzyy.lastIndexOf("\/");
        gzyy = gzyy.substring(index + 1, gzyy.length);
        $("#whjl_input").val("该设备" + getdate() + "由于" + gzyy + "进行设备维护，维护方法为" + jjfa)
    })

    //我之前做的保存维护记录开始
    function savesbwh() {
        var sbbh01 = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        var bmid = $("#selectbm option:selected").val();//新的部门id
        var bmmc = $("#selectbm option:selected").text().replace(/\s+/g, "");//新的部门名称
        var shiyr = $("#shiyr01").val();//新的设备使用人
        var bmmc_hidden = $("#bmmc_hidden").val();//原部门id（隐藏的）
        var shiyr_sjk = getshiyr(sbbh01)
        var bmid_sjk = getbmid(sbbh01);
        var bmmc_sjk = getbmmcsjk(bmmc_hidden);
        var gzyy=$("#gzyy_update_input_15 option:selected").val()
        var jjfa=$("#jjfa_update_input_15 option:selected").val()
        var gzyyT=$("#gzyy_update_input_15 option:selected").text()
        var jjfaT=$("#jjfa_update_input_15 option:selected").text()
        //部门和使用人相同
        if (shiyr==shiyr_sjk&&bmid==bmid_sjk&&gzyy=="0"){
            // alert("部门、使用人、故障原因、解决方案都未改变，这里不需要插入任何数据")
            $.alert("你未进行任何操作，不必添加任何的维护记录，你最起码要修改点数据吧！！！")
        }

        if (shiyr==shiyr_sjk&&bmid==bmid_sjk&&gzyy!="0"&&jjfa=="0"){
            // alert("部门、使用人未改变,故障原因改变了，这里需要提醒请选择解决方案")
            $.alert("请选择解决方案")
        }

        if (shiyr==shiyr_sjk&&bmid==bmid_sjk&&gzyy!="0"&&jjfa!="0"){
            // alert("部门、使用人未改变,故障原因、解决方案改变，这里需要插入一条故障原因与解决方案的维护记录")
            insertsbwhb()
        }

        //部门使用人都维护了
        if (shiyr!=shiyr_sjk&&bmid!=bmid_sjk&&gzyy=="0"){
            // alert("部门和使用人修改了，故障原因与解决方案未选择，这里插入一条部门与使用人维护的一条记录")
            $("#whjl_input").val("该设备" + getdate() + "的使用部门由" + bmmc_sjk+"-"+shiyr_sjk + "维护成" + bmmc+"-"+shiyr)
            updatesbxxb(spid);
            insertsbwhb()
        }

        if (shiyr!=shiyr_sjk&&bmid!=bmid_sjk&&gzyy!="0"&&jjfa=="0"){
            // alert("部门和使用人修改了，故障原因选择了，提示请选择解决方案")
            $.alert("请选择解决方案");
        }

        if (shiyr!=shiyr_sjk&&bmid!=bmid_sjk&&gzyy!="0"&&jjfa!="0"){
            // alert("部门、使用人、故障原因、解决方案都修改了，这里需要插入2条记录，一条维护部门使用人，一条维护故障原因解决方案")
            $("#whjl_input").val("该设备" + getdate() + "的使用部门由" + bmmc_sjk+"-"+shiyr_sjk + "维护成" + bmmc+"-"+shiyr)
            updatesbxxb(spid);
            insertsbwhbnotgb()
            $("#whjl_input").val("该设备" + getdate() + "由于【" + gzyyT + "】进行设备维护，维护方法为【" + jjfaT+"】")
            insertsbwhb()
        }
        var bmidbyshiyr = getdeptbyshiyr(shiyr)
        //维护使用人
        if (shiyr!=shiyr_sjk&&bmid==bmid_sjk&&gzyy=="0"&&bmidbyshiyr!=bmid){
            alert("使用人维护了，部门、故障原因、解决方案都未修改，但是使用人与部门不一致")
        }

        if (shiyr!=shiyr_sjk&&bmid==bmid_sjk&&gzyy=="0"&&bmidbyshiyr==bmid){
            alert("使用人维护了，部门、故障原因、解决方案都未修改，提示插入一条维护使用人的维护记录")
        }

        if (shiyr!=shiyr_sjk&&bmid==bmid_sjk&&gzyy!="0"&&jjfa=="0"){
            alert("使用人、故障原因维护了，部门、解决方案都未修改，这里提示请选择解决方案")
        }

        if (shiyr!=shiyr_sjk&&bmid==bmid_sjk&&gzyy!="0"&&jjfa!="0"&&bmidbyshiyr!=bmid){
            alert("修改了使用人但是使用人的部门不对，提示使用人部门与表单的部门不一致")
            // alert("使用人、故障原因、解决方案都修改了，部门为维护，这里需要插入2条记录，一条维护部门使用人，一条维护故障原因解决方案")
        }

        if (shiyr!=shiyr_sjk&&bmid==bmid_sjk&&gzyy!="0"&&jjfa!="0"&&bmidbyshiyr==bmid){
            alert("使用人、故障原因、解决方案都修改了，部门为维护，这里需要插入2条记录，一条维护部门使用人，一条维护故障原因解决方案")
        }

        // if (!gzyy){
        //     alert("请选择故障原因！")
        //     return false
        // }
        // if (gzyy!=""&&jjfa==""){
        //     alert("请选择故障解决方案！")
        //     return false
        // }
        // if (gzyy!=""&&jjfa!=""){
        //     // insertsbwhb();
        //     alert("故障原因和解决方案都不相同")
        //     return false
        // }
        // if (shiyr!=shiyr_sjk||bmid!=bmid_sjk){
        //     alert("人员不符或部门不符")
        //     updatesbxxb(spid);
        //     $("#whjl_input").val("该设备" + getdate() + "的使用部门由" + bmmc_sjk+"-"+shiyr_sjk + "维护成" + bmmc+"-"+shiyr)
        //     insertsbwhb()
        // }
        // if(shiyr_sjk==shiyr&&bmid==bmid_sjk){
        //     alert("部门人员相符不做处理")
        //     $("#whjl_input").val("该设备" + getdate() + "由于【" + gzyyT + "】进行设备维护，维护方法为【" + jjfaT+"】")
        //     insertsbwhb();
        // }
    }

    //我之前做的保存维护记录结束

    //通过使用人查询出部门的ID号
    function getdeptbyshiyr(shiyr) {
        var bmid=""
        $.ajax({
            url: "/nc/ygxxb/getbmidbyshiyr/" + shiyr,
            type: 'GET',
            async: false,
            success: function (result) {
                bmid=result
            }
        });
        return bmid;
    }

    function sbwhjm() {
        $.confirm({
            title: '故障原因与解决方案维护',
            content: '' +
                '<form action="" class="sbwhjmform">' +
                '<div class="form-group">' +
                '<label>请先输入硬盘大小后，点击下拉框选择硬盘单位</label>' +
                '<select class="gzyy form-control" name="gzyy" id="gzyy_sbwhjm"></select>' +
                '<select class="jjfa form-control" name="jjfa" id="jjfa_sbwhjm"></select>' +
                '<input type="hidden" placeholder="请输入部门ID号" class="form-control" name="bmid" id="bmid_sbwhjm"/>' +
                '<input type="hidden" placeholder="请输入设备ID号" class="form-control" name="sbid" id="sbid_sbwhjm"/>' +
                '<input type="hidden" placeholder="请输入设备编号" class="form-control" name="sbbh" id="sbbh_sbwhjm"/>' +
                '<label style="width: 60px">维护人：</label>' +
                '<input type="text" readonly="readonly" name="weihr" id="weihr_sbwhjm" style="width: 80px"/>' +
                '<input type="hidden" placeholder="请输入使用人" class="form-control" name="shiyr" id="shiyr_sbwhjm"/>' +
                '<input type="hidden" placeholder="请输入维护记录" class="form-control" name="whjl" id="whjl_sbwhjm"/>' +
                '<input type="hidden" placeholder="请输入原部门名称" class="form-control" name="ybmmc" id="ybmmc_sbwhjm"/>' +
                '<input type="hidden" placeholder="请输入原设备使用人" class="form-control" name="yshiyr" id="yshiyr_sbwhjm"/>' +
                '</div>' +
                '</form>',
            buttons: {
                formSubmit: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        var gzyy = this.$content.find('.gzyy').val();
                        var jjfa = this.$content.find('.jjfa').val();
                        if(!gzyy){
                            $.alert('1');
                            return false;
                        }if(!jjfa){
                            $.alert('2');
                            return false;
                        }
                        if (gzyy!=""&&jjfa!=""){
                            alert(3)
                            return false;
                        }
                        // return $.ajax({
                        //     url: '/nc/sbwhb/insertsbwh',
                        //     dataType: 'json',
                        //     method: 'POST',
                        //     data: $(".formName").serialize(),
                        // }).done(function (data) {
                        //     $.ajax("添加成功！！！");
                        //     window.location.href = window.location.href;
                        // })
                    }
                },
                cancel: function () {
                    //close
                },
            },
            onOpen:function(){
                return $.ajax({
                    url: '/nc/sbflb/getname/',
                    dataType: 'json',
                    method: 'get'
                }).done(function (data) {
                    $('.gzyy').empty();
                    var options = "";   //字符串拼接
                    $('.gzyy').append('<option value="">请选择故障原因</option>');
                    for (var i in data) {  //遍历json数组
                        options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                        //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                    }
                    $('.gzyy').append(options);
                    $('.gzyy').change(function () {
                        var sbwhid = $('.gzyy').val();
                        return $.ajax({
                            url: '/nc/sbflb/getnamebyans/' + sbwhid,
                            dataType: 'json',
                            method: 'get'
                        }).done(function (data) {
                            $('.jjfa').empty();
                            var options = "";   //字符串拼接
                            $('.jjfa').append('<option value="">请选择故障原因</option>');
                            for (var i in data){
                                options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                            }
                            $('.jjfa').append(options);
                        })
                    })
                    $('#jjfa_sbwhjm').change(function () {
                        return $.ajax({
                            url: "/nc/sbxxb/getsbwh/" + spid,
                            dataType: 'json',
                            method: 'GET'
                        }).done(function (data) {
                            $('#bmid_sbwhjm').val(data[0].bmid)
                            $('#sbid_sbwhjm').val(data[0].id)
                            $('#sbbh_sbwhjm').val(data[0].sbbh)
                            $('#weihr_sbwhjm').val(sessionname)
                            $('#shiyr_sbwhjm').val(data[0].shiyr)
                            $('#ybmmc_sbwhjm').val(getbmmcsjk(data[0].bmid))
                            $('#yshiyr_sbwhjm').val(getshiyr(spid))
                            var gzyy = $("#gzyy_sbwhjm option:selected").text();
                            var jjfa = $("#jjfa_sbwhjm option:selected").text();
                            var index = gzyy.lastIndexOf("\/");
                            gzyy = gzyy.substring(index + 1, gzyy.length);
                            $("#whjl_sbwhjm").val("该设备" + getdate() + "由于【" + gzyy + "】进行设备维护，维护方法为【" + jjfa+"】")
                        })
                    })
                })
            }
        });
    }

    function rywhjm() {
        $.confirm({
            title: '部门与人员维护',
            content: '' +
                '<form action="" class="rywhjmform">' +
                '<div class="form-group">' +
                '<label>请先选择部门名称，点击下拉框选择设备使用人</label>' +
                '<select class="bmmc form-control" name="bmid" id="bmmc_rywhjm"></select>' +
                '<input name="shiyr" id="shiyr_rywhjm" class="shiyr form-control" list="browsers"><datalist id="browsers"></datalist>' +
                '<input type="hidden" placeholder="请输入部门ID号" class="form-control" name="bmid" id="bmid_rywhjm"/>' +
                '<input type="hidden" placeholder="请输入设备ID号" class="form-control" name="sbid" id="sbid_rywhjm"/>' +
                '<input type="hidden" placeholder="请输入设备编号" class="form-control" name="sbbh" id="sbbh_rywhjm"/>' +
                '<label style="width: 60px">维护人：</label>' +
                '<input type="text" readonly="readonly" name="weihr" id="weihr_rywhjm" style="width: 80px"/>' +
                '<input type="hidden" placeholder="请输入使用人" class="form-control" name="shiyr" id="shiyr_rywhjm"/>' +
                '<input type="hidden" placeholder="请输入维护记录" class="form-control" name="whjl" id="whjl_rywhjm"/>' +
                '<input type="hidden" placeholder="请输入原部门名称" class="form-control" name="ybmmc" id="ybmmc_rywhjm"/>' +
                '<input type="hidden" placeholder="请输入原设备使用人" class="form-control" name="yshiyr" id="yshiyr_rywhjm"/>' +
                '</div>' +
                '</form>',
            buttons: {
                formSubmit: {
                    text: '确定',
                    btnClass: 'btn-blue',
                    action: function () {
                        var bmmc = this.$content.find('.bmmc').val();
                        var shiyr = this.$content.find('.shiyr').val();
                        var ybmid=getbmid(spid)
                        var yshiyr=getshiyr(spid)
                        if(bmmc!=ybmid||shiyr!=yshiyr){
                            $.alert('4');
                            return false;
                        }
                        if(bmmc==ybmid||shiyr==yshiyr)
                            alert(5)
                            return false;
                        // return $.ajax({
                        //     url: '/nc/sbwhb/insertsbwh',
                        //     dataType: 'json',
                        //     method: 'POST',
                        //     data: $(".rywhjmform").serialize(),
                        // }).done(function (data) {
                        //     $.ajax("添加成功！！！");
                        //     window.location.href = window.location.href;
                        // })
                    }
                },
                cancel: function () {
                    //close
                },
            },
            onOpen:function(){
                return $.ajax({
                    url: '/nc/bmxxb/getbmxx/',
                    dataType: 'json',
                    method: 'get'
                }).done(function (data) {
                    $('.bmmc').empty();
                    var options = "";   //字符串拼接
                    $('.bmmc').append('<option value="">请选择部门</option>');
                    for (var i in data) {  //遍历json数组
                        options += "<option value='" + data[i].id + "'>" + data[i].bmmc + "</option>"
                        //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                    }
                    $('.bmmc').append(options);
                    $('.bmmc').change(function () {
                        var bmid = $('.bmmc').val();
                        return $.ajax({
                            url: '/nc/ygxxb/getygxx/'+ bmid,
                            dataType: 'json',
                            method: 'get'
                        }).done(function (data) {
                            $('#shiyr_rywhjm').empty();
                            $("#browsers").empty();
                            var options = "";   //字符串拼接
                            for (var i in data) {  //遍历json数组
                                options += "<option value='" + data[i].xingm + "'>" + data[i].zjm + "</option>"
                                //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                            }
                            $('#browsers').append(options);
                        })
                    })
                    
                    $('.shiyr').change(function () {
                        
                    })
                })
            }
        });
    }

    function insertwhjl() {
        $.confirm({
            title: '请选择!',
            content: '维护故障原因与解决方案请点击维护设备，设备使用部门与使用人改变请点击维护人员，如果都需要维护请点击全部',
            buttons: {
                sbwh: {
                    text: '设备维护',
                    btnClass: 'btn-blue',
                    keys: ['enter', 'shift'],
                    action: function(){
                        sbwhjm();
                    }
                },
                rywh: {
                    text: '人员维护',
                    btnClass: 'btn-blue',
                    keys: ['enter', 'shift'],
                    action: function(){
                        rywhjm()
                    }
                }
            }
        });
    }

    //通过设备编号获取原部门id
    function getbmid(sbbh) {
        var bmid=0
        $.ajax({
            url: "/nc/sbxxb/getbmid/" + sbbh,
            type: 'GET',
            async: false,
            success: function (result) {
                bmid = result
            }
        });
        return bmid
    }

    function xinncdx(sbbh) {
        var xinncdx=""
        $.ajax({
            url: "/nc/sbxxb/getsbwh/" + sbbh,
            type: 'GET',
            async: false,
            success: function (result) {
                xinncdx=result[0].ncggdx
            }
        })
        return xinncdx;
    }

    //通过部门id获取部门名称
    function getbmmcsjk(bmid) {
        var bmmc=""
        $.ajax({
            url: "/nc/bmxxb/getbmmc/" + bmid,
            type: 'GET',
            async: false,
            success: function (result) {
                if (result != null) {
                    bmmc = result.replace(/\s+/g, "");
                    // result.replace(/\s+/g,"");替换所有空格
                    // result.replace(/^\s+|\s+$/g,"");替换前后空格
                }
            }
        });
        return bmmc;
    }

    //通过设备编号获取原使用人
    function getshiyr(sbbh) {
        var shiyr=""
        $.ajax({
            url: "/nc/sbxxb/getshiyr/" + sbbh,
            type: 'GET',
            async: false,
            success: function (result) {
                if (result != null) {
                    shiyr = result;
                }
            }
        })
        return shiyr
    }

    //通过设备编号获取原使用人
    function getygid(xingm) {
        var ygid=""
        $.ajax({
            url: "/nc/ygxxb/getygid/" + xingm,
            type: 'GET',
            async: false,
            success: function (result) {
                if (result != null) {
                    ygid = result;
                }
            }
        })
        return ygid
    }
    // 通过设备编号更新设备信息表
    function updatesbxxb(sbbh) {
        $.ajax({
            url: "/nc/sbxxb/updatesbxxbbywh/" + sbbh,
            type: "put",
            async: false,
            data: $("#myModal5 form").serialize(),
            success: function (data) {
                alert("设备表更新成功")
            }
        })
    }

    function updatesbxxbbywh(sbbh) {
        $.ajax({
            url: "/nc/sbxxb/updatesbxxbbywh/" + sbbh,
            type: "put",
            async: false,
            data: $(".shiyrformName").serialize(),
            success: function (data) {
                alert("设备表更新成功")
            }
        })
    }

    // 插入设备维护表
    function insertsbwhb() {
        $.ajax({
            url: "/nc/sbwhb/insertsbwh",
            type: 'POST',
            async: false,
            data: $("#myModal5 form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#myModal5").modal('hide');
                    window.location.href = window.location.href;
                }
            }
        });
    }

    // 插入设备维护表
    function insertsbwhbnotgb() {
        $.ajax({
            url: "/nc/sbwhb/insertsbwh",
            type: 'POST',
            async: false,
            data: $("#myModal5 form").serialize(),
            success: function (result) {
                if (result != null) {
                }
            }
        });
    }

    function shengji() {
        var sbbh01 = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        var ly_sbbh=($("#ly_sbbh option:selected").val());
        // alert(xinncdx(ly_sbbh))//报废电脑剩余的内存大小
        var shenyu = xinncdx(ly_sbbh)
        shenyu=shenyu.substr(0, shenyu.length-1);
        var benncdx= xinncdx(sbbh01)
        benncdx=benncdx.substr(0, benncdx.length-1);
        var shuruncdx= $("#sbsj_ncggdx").val()
        shuruncdx=shuruncdx.substr(0, shuruncdx.length-1);
        var zhege=shuruncdx-benncdx
        alert(zhege)
        if(zhege>shenyu){
            alert("你输入的内存大小出错了，请认真核对后重新输入")
        }
        $("#ncggdx01").attr("value", $("#sbsj_ncggdx").val())
        $.ajax({
            url: "/nc/sbxxb/updatesbxxb/" + sbbh01,
            type: "put",
            async: false,
            data: $("#sbshenjModal form").serialize(),
            success: function (data) {
                alert("设备表更新成功")
            }
        });
        $.ajax({
            url: "/nc/sbsjb/insertshenji",
            type: 'POST',
            async: false,
            data: $("#sbshenjModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#sbshenjModal").modal('hide');
                    window.location.href = window.location.href;
                }
            }
        });
    };

    function baofei() {
        var sbbh01 = document.getElementsByTagName("td")[0].firstChild.nodeValue;
        if (confirm("确认报废编号为【" + sbbh01 + "】的设备吗？")) {
            $.ajax({
                url: "/nc/sbxxb/updatesbxxbbybf/" + sbbh01,
                type: "put",
                async: false,
                data: $("#sbbaofModal form").serialize(),
                success: function (data) {
                    alert("设备表更新成功")
                }
            });
            $.ajax({
                url: "/nc/sbbfb/insertbaof",
                type: 'POST',
                async: false,
                data: $("#sbbaofModal form").serialize(),
                success: function (result) {
                    if (result != null) {
                        alert("添加成功！！！");
                        $("#sbbaofModal").modal('hide');
                        window.location.href = window.location.href;
                    }
                }
            });
        }
    };


    $('#add_jjfa').click(function () {
        var bmid = $("#gzyy_update_input_15 option:selected").val();
        var ansid = $("#ancestorsfrowh").val();
        if (bmid == "") {
            alert("请先选择故障原因,然后再点击添加解决办法！！！")
        } else {
            $('#myModal5').modal('toggle');
            $("#tjjjfaModal").modal({
                backdrop: "static"
            });
            $("#gzyy_fl").val($("#gzyy_update_input_15 option:selected").text())
            $.ajax({
                url: "/nc/sbflb/maxid/",
                type: 'GET',
                success: function (data) {
                    sbbh = (parseInt(data) + 1);
                    $("#idhao").val(sbbh);
                    $("#parent_id").val(bmid);
                    $("#ancestors").val(ansid + "," + bmid);
                    // $('#myModal5').modal('toggle');
                },
            })
        }
    });

    function tjjjfa() {
        $.ajax({
            url: "/nc/sbflb/insertfl",
            type: 'POST',
            async: false,
            data: $("#tjjjfaModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#tjjjfaModal").modal('hide');
                    var sbwhid = $("#gzyy_update_input_15 option:selected").val();
                    $.ajax({
                        url: "/nc/sbflb/getnamebyans/" + sbwhid,
                        type: 'GET',
                        async: false,
                        success: function (data) {
                            $('#jjfa_update_input_15').empty();
                            var options = "";   //字符串拼接
                            $("#jjfa_update_input_15").append('<option value="">请选择解决方案</option>');
                            for (var i in data) {  //遍历json数组
                                options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                                //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                            }
                            $('#jjfa_update_input_15').append(options);
                        }

                    })
                    $('#myModal5').modal('show');
                }
            }
        });
    };


    $('#add_yg').click(function () {
        // var bmid = $("#selectbm option:selected").val();
        // if (bmid == "") {
        //     alert("请先选择部门名称,然后再点击添加部门员工！！！")
        // } else {
        //     $('#myModal5').modal('toggle');
        //     $("#ygModal").modal({
        //         backdrop: "static"
        //     });
        //     $("#yg_bmmc").val($("#selectbm option:selected").text())
        // }
        $.confirm({
            title: '人员管理!',
            content: '新添加员工请选择新增人员，使用人变更部门请选择人员变更，变更前一定要在上一个页面中选择部门',
            buttons: {
                confirm: {
                    text: '新增人员',
                    btnClass: 'btn-blue',
                    action: function(){
                        var bmid = $("#selectbm option:selected").val();
                        if (bmid=="0") {
                            alert("您在上个页面未选择部门，请关闭当前页面后选择使用人所在的部门")
                        }else {
                            $('#myModal5').modal('toggle');
                            $.confirm({
                                title: '新增人员',
                                content: '' +
                                    '<form action="" class="formName">' +
                                    '<div class="form-group">' +
                                    '<div class=""><label>部门</label>' +
                                    '<input type="text" placeholder="请输入部门名称" class="bmmc"/><input type="hidden" placeholder="请输入部门名称" name="bmid" id="bmid_con"/></div>' +
                                    '<div class=""><label>新增人员</label>' +
                                    '<input type="text" placeholder="请输入新增人员的姓名" id="yg_xingm" name="xingm" class="shiyr"/></div>' +
                                    '</div>' +
                                    '</form>',
                                buttons: {
                                    formSubmit: {
                                        text: '确定',
                                        btnClass: 'btn-blue',
                                        action: function () {
                                            // var name = this.$content.find('.name').val();
                                            // if(!name){
                                            //     $.alert('provide a valid name');
                                            //     return false;
                                            // }
                                            // $.alert('Your name is ' + name);
                                            var name = this.$content.find('.shiyr').val();
                                            if (!name){
                                                $.alert('您未输入姓名，请输入使用人的姓名');
                                                return false
                                            } else {
                                            return $.ajax({
                                                url: '/nc/ygxxb/insertyg',
                                                dataType: 'json',
                                                method: 'POST',
                                                data: $(".formName").serialize(),
                                                }).done(function (data) {
                                                    $.ajax("添加成功！！！");
                                                window.location.href = window.location.href;
                                            })}
                                        }
                                    },
                                    cancel: function () {
                                        //close
                                    },
                                },
                                onContentReady: function () {
                                    var bmid = $("#selectbm option:selected").val();
                                    var bmmc = getbmmcsjk(bmid)
                                    $('.bmmc').val(bmmc)
                                    $("#bmid_con").val(bmid)
                                }
                            });
                        }
                    }
                },
                cancel: {
                    text: '人员变动',
                    btnClass: 'btn-blue',
                    action: function(){
                        var bmid = $("#selectbm option:selected").val();
                        if (bmid=="0") {
                            alert("您在上个页面未选择部门，请关闭当前页面后选择使用人所在的部门")
                        }else {
                            $('#myModal5').modal('toggle');
                            $.confirm({
                                title: '人员变动',
                                content: '' +
                                    '<form action="" class="shiyrformName">' +
                                    '<div class="form-group">' +
                                    '<div class=""><label>原部门：</label>' +
                                    '<input type="text" placeholder="请输入部门名称" class="bmmc"/><input type="hidden" placeholder="请输入部门名称" id="bmid_con"/></div>' +
                                    '<div class=""><label>使用人：</label>' +
                                    '<input type="text" placeholder="请输入新增人员的姓名" id="yxingm"/><input type="hidden" id="shiyr_sbbh" name="sbbh"/></div>' +
                                    '<div class=""><label>现部门：</label>' +
                                    '<select type="text" id="xxingm" name="bmid"></select></div>' +
                                    '</div>' +
                                    '</form>',
                                buttons: {
                                    formSubmit: {
                                        text: '确定',
                                        btnClass: 'btn-blue',
                                        action: function () {
                                            var xbmid = $("#xxingm option:selected").val();//得到部门ID
                                            // var ygid = getygid($("#yxingm").val())//通过使用人的姓名得到id号
                                            var yxingm=$("#yxingm").val()
                                            alert(shiyr_sbbh)
                                            if (!xbmid){
                                                $.alert('您未选择使用人的部门，请选择');
                                                return false
                                            } else {
                                                return $.ajax({
                                                    url: '/nc/ygxxb/updateygxxb/'+yxingm,
                                                    dataType: 'json',
                                                    method: 'PUT',
                                                    data: $(".formName").serialize(),
                                                }).done(function (data) {
                                                    $.ajax("更新成功！！！");
                                                    updatesbxxbbywh(spid)
                                                    window.location.href = window.location.href;
                                                })}
                                        }
                                    },
                                    cancel: function () {
                                        //close
                                    },
                                },
                                onContentReady: function () {
                                    var bmid = $("#selectbm option:selected").val();
                                    var shiyr = $("#shiyr01").val();
                                    $("#yxingm").val(shiyr)
                                    var bmmc = getbmmcsjk(bmid)
                                    $('.bmmc').val(bmmc)
                                    $("#bmid_con").val(bmid)
                                    $("#shiyr_sbbh").val(spid);
                                    return $.ajax({
                                        url: '/nc/bmxxb/getbmxx',
                                        dataType: 'json',
                                        method: 'get',
                                    }).done(function (data) {
                                        $('#xxingm').empty();
                                        var options = "";   //字符串拼接
                                        $('#xxingm').append('<option value="">请选择部门</option>');
                                        for (var i in data) {  //遍历json数组
                                            options += "<option value='" + data[i].id + "'>" + data[i].bmmc + "</option>"
                                            //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                                        }
                                        $('#xxingm').append(options);
                                    })
                                }
                            });
                        }
                    }
                }
            }
        });
    });

    $('#creat_zjm_btn').click(function () {
            var zjm = $('#yg_xingm').val();
            if (zjm == "") {
                alert("请先在姓名输入框中输入姓名后，再点击生成助记码！！！")
            } else {
                $.ajax({
                    url: "/nc/ygxxb/getzjm/" + zjm,
                    type: 'GET',
                    success: function (result) {
                        $("#yg_zjm").val(result);
                    }
                })
            }
        }
    )

    $('#creat_zjm_btn_con').click(function () {
            alert("我的名字")
            var zjm = $('#yg_xingm').val();
            if (zjm == "") {
                alert("请先在姓名输入框中输入姓名后，再点击生成助记码！！！")
            } else {
                $.ajax({
                    url: "/nc/ygxxb/getzjm/" + zjm,
                    type: 'GET',
                    success: function (result) {
                        $("#yg_zjm").val(result);
                    }
                })
            }
        }
    )


    function tjjjfa() {
        $.ajax({
            url: "/nc/sbflb/insertfl",
            type: 'POST',
            async: false,
            data: $("#tjjjfaModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#tjjjfaModal").modal('hide');
                    var sbwhid = $("#gzyy_update_input_15 option:selected").val();
                    $.ajax({
                        url: "/nc/sbflb/getnamebyans/" + sbwhid,
                        type: 'GET',
                        async: false,
                        success: function (data) {
                            $('#jjfa_update_input_15').empty();
                            var options = "";   //字符串拼接
                            $("#jjfa_update_input_15").append('<option value="">请选择解决方案</option>');
                            for (var i in data) {  //遍历json数组
                                options += "<option value='" + data[i].id + "'>" + data[i].name + "</option>"
                                //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                            }
                            $('#jjfa_update_input_15').append(options);
                        }

                    })
                    $('#myModal5').modal('show');
                }
            }
        });
    };


    function tjyg() {
        $("#yg_bmid").val($("#selectbm option:selected").val());
        $.ajax({
            url: "/nc/ygxxb/insertyg",
            type: 'POST',
            async: false,
            data: $("#ygModal form").serialize(),
            success: function (result) {
                if (result != null) {
                    alert("添加成功！！！");
                    $("#ygModal").modal('hide');
                    var bmid = $("#selectbm option:selected").val();
                    $('#shiyr01').val("");
                    $('#browsers').empty();
                    $.ajax({
                        url: "/nc/ygxxb/getygxx/" + bmid,
                        type: 'get',
                        success: function (data) {
                            $('#shiyr01').empty();
                            var options = "";   //字符串拼接
                            for (var i in data) {  //遍历json数组
                                options += "<option value='" + data[i].xingm + "'>" + data[i].zjm + "</option>"
                                //     // "<input type='radio' class='roles' name='roles' id='"+data[i].wjdcs+"' value='"+data[i].wjdc+"'>"+data[i].wjdc+"&nbsp;&nbsp;"
                            }
                            $('#browsers').append(options);
                        },
                    });
                    $('#myModal5').modal('show');
                }
            }
        });
    };

</script>
</body>
</html>